﻿namespace EFS.RC.Survey
{
	public partial class ListExternal : EFS.RC.Survey.Controls.Common.Pages.Controls.Control
	{
		#region Locals
		/// reviewTypeSessions
		private EFS.RC.CC.CH.Entities.Surveys.SurveyInfo.eReviewType? reviewTypeSessions = null;
		#endregion

		#region Constructors
		/// Implicit
		public ListExternal()
		{
			InitializeComponent();

			// do not use this
			ConstructorNotAllowed();
		}

		/// Explicit
		public ListExternal(
			System.Guid conversationGuid,
			EFS.RC.CC.CH.Entities.Surveys.SurveyInfo.eReviewType? reviewTypeSessions)
		{
			// check
			EFS.Common.Verify.Guid(conversationGuid, "conversationGuid");

			// init componet
			InitializeComponent();

			// set
			this.ConversationGuid = conversationGuid;
			this.reviewTypeSessions = reviewTypeSessions;
		}
		#endregion

		#region Properties
		/// Property ConversationGuid: Get, Set
		public System.Guid ConversationGuid { get; private set; }

		/// Property SurveyObj: Get, Set
		public EFS.RC.CC.CH.Entities.Surveys.SurveyInfo SurveyObj { get; private set; }
		#endregion

		#region LoadData
		/// LoadData
		private void LoadData()
		{
			// create new
			EFS.Common.UI.Controls.ModalDialogHost wnd = new EFS.Common.UI.Controls.ModalDialogHost();
			wnd.ButtonOKVisible = false;
			EFS.RC.Survey.Controls.List surveyList = new EFS.RC.Survey.Controls.List(wnd, ConversationGuid, this.reviewTypeSessions);
			surveyList.OnOpenSurvey = OpenSurvey;
			wnd.HostedContent = surveyList;
			wnd.Show(null);
		}
		#endregion

		#region Utilities
		/// <summary>
		/// Open survey in place 
		/// </summary>
		/// <param name="surver"></param>
		private void OpenSurvey(EFS.RC.CC.CH.Entities.Surveys.Sessions.SessionInfo surveyInfo)
		{
			// open score in new browser
			EFS.RC.Survey.Common.Functions.StartSurveyExternal(ConversationGuid, surveyInfo.Survey.ID.Value);
		}
		#endregion

		#region Events
		/// Loaded
		private void Control_Loaded(object sender, System.Windows.RoutedEventArgs e)
		{
			LoadData();
		}
		#endregion
	}

}